package com.gzhryc.shared_device.oem.code.business;

import com.gzhryc.shared_device.bxscn.core.BXSCNConstants;
import com.gzhryc.shared_device.cdb.core.CDBConstants;
import com.gzhryc.shared_device.cdcz.core.CDCZConstants;
import com.gzhryc.shared_device.oem.code.BaseConstants;
import com.gzhryc.shared_device.pcl.core.PCLConstants;

import java.util.ArrayList;
import java.util.List;

/**
 * 业务类型枚举，用于订单对象
 */
public enum EBusinessType {

    RECHARGE("Recharge", "会员充值"), CDCZ(CDCZConstants.BusinessType, "充电插座"), CDB(CDBConstants.BusinessType, "共享充电宝")
    , BXSCN(BXSCNConstants.BusinessType, "便携式储能电池"), BXSCN_SHOP(BXSCNConstants.BusinessTypeShop, "便携式储能电池(门店)")
    , PCL(PCLConstants.BusinessType, "便捷线充")
    , MARKET("Market", "购买商品")
    
    
    ,NORMAL("Normal","通用业务");

    private String index;
    private String note;

    EBusinessType(String index, String note) {
        this.index = index;
        this.note = note;
    }

    public String index() {
        return index;
    }

    public String note() {
        return note;
    }

    public static String note(String index) {
        EBusinessType[] temp = EBusinessType.values();
        for (int i = 0; i < temp.length; i++) {
            EBusinessType item = temp[i];
            if (item.index.equals(index)) {
                return item.note;
            }
        }
        return null;
    }
    
    public static EBusinessType getByIndex(String index) {
    	 EBusinessType[] temp = EBusinessType.values();
         for (int i = 0; i < temp.length; i++) {
             EBusinessType item = temp[i];
             if (item.index.equals(index)) {
                 return item;
             }
         }
         return null;
    }

    public static List<EBusinessType> findBusinessTypes(){
        List<EBusinessType> businessTypeList = new ArrayList<>();
        if(BaseConstants.getCDB()) {
            businessTypeList.add(EBusinessType.CDB);
        }
        if(BaseConstants.getCDCZ()) {
            businessTypeList.add(EBusinessType.CDCZ);
        }
        if(BaseConstants.getPCL()) {
            businessTypeList.add(EBusinessType.PCL);
        }
        if(BaseConstants.getBXSCN()) {
            businessTypeList.add(EBusinessType.BXSCN);
            businessTypeList.add(EBusinessType.BXSCN_SHOP);
        }
        return businessTypeList;
    }
}
